<?php
include_once BONE_ROOT.DS.APP_DIR.DS.'templates'.DS.'product'.DS.'product.php';

class template_edit extends template_product
{

	protected function head()
	{
		$this->load_editor();
	}

	protected function center()
	{
		$product_id = $this->get('product_id');
		$product = $this->get('product');
		$categories = $this->get('categories');
		
		$this->toolbar();
		?>

<div class="box">
	<div class="box-tl"><div class="box-tr"><div class="box-tm"></div></div></div>	
	<div class="box-m">
		
		<h3 class="title"><?php echo $this->get_title(); ?></h3>
		<form action="./" method="post" enctype="multipart/form-data">
		<table class="edit-table">
		<tbody>
		<tr>
		<td class="key">产品名</td>
		<td><input type="text" name="name" value="<?php echo $product->name; ?>" style="width:500px;" /></td>
		</tr>
		<tr>
		<td class="key">所属分类</td>
		<td>
		<select name="category_id">
		<?php 
		foreach($categories as $category)
		{
			echo '<option value="'.$category->id.'"';
			if($category->id == $product->category_id) echo ' selected';
			echo '> - '.$category->name.' - </option>';
		}
		?>
		</select>
		</td>
		</tr>

		<tr>
		<td class="key">内容</td>
		<td><?php $this->editor('description', $product->description, '600px', '400px'); ?></td>
		</tr>
		
		<tr>
		<td class="key">图像</td>
		<td>
		<?php if($product->image){ ?>
		<img src="../storage/product/<?php echo $product->image; ?>" />
		<?php } ?>
		<input type="file" name="image"/>
		</td>
		</tr>
		
		<tr>
		<td class="key">价格</td>
		<td><input type="text" name="price" value="<?php echo $product->price; ?>" /></td>
		</tr>
		
		<tr>
		<td class="key">点击量</td>
		<td><input type="text" name="hits" value="<?php echo $product->hits; ?>" /></td>
		</tr>
		
		<tr>
		<td class="key"><a href="javascript:;" onclick="javascript:$('#seo-fields').toggle();">SEO</a></td>
		<td>
		<div id="seo-fields" <?php if(!($product->meta_keywords || $product->meta_description) ){ ?>class="hide"<?php } ?>>
			Mata Keywords <br><textarea name="meta_keywords" style="width:500px; height:60px;"><?php echo $product->meta_keywords; ?></textarea><br>
			Meta Description <br><textarea name="meta_description" style="width:500px; height:60px;"><?php echo $product->meta_description; ?></textarea>
		</div>
		</td>
		</tr>
		
		<tr>
		<td class="key"></td>
		<td>
		<input class="btn" type="submit" value="保存" /> <input class="btn" type="button" value="返回" onclick="javascript:window.history.go(-1);" />
		</td>
		</tr>
		</tbody>
		</table>
		<input type="hidden" name="id" value="<?php echo $product->id; ?>" />
		<input type="hidden" name="controller" value="product" />
		<input type="hidden" name="task" value="edit_save" />
		</form>
	</div>
	<div class="box-bl"><div class="box-br"><div class="box-bm"></div></div></div>
</div>
		

		<?php
		
	}	

}
?>